/*
 * ilogger.h
 *
 *  Created on: 17/01/2013
 *      Author: datys
 */

#ifndef ILOGGER_H_
#define ILOGGER_H_

#include <cstdarg>
#include <string>

namespace slf4cxx {

/**
 * Represents a simple logging façade.
 */
class ILogger {
private:
	static ILogger* _current;
	static const std::string LoggerLevelText[5];

public:
	/**
	 * Log level.
	 */
	enum ILoggerLevel {
		ILOGGER_DEBUG = 0, //!< ILOGGER_DEBUG Debug level.
		ILOGGER_INFO = 1, //!< ILOGGER_INFO Information level.
		ILOGGER_WARNING = 2, //!< ILOGGER_WARNING Warning level.
		ILOGGER_ERROR = 3, //!< ILOGGER_ERROR Error level.
		ILOGGER_FATAL = 4, //!< ILOGGER_FATAL Fatal level.
	};

	/**
	 * Create a new instance of the ILogger class.
	 */
	ILogger() {
	}

	/**
	 * Deallocates resources.
	 */
	virtual ~ILogger() {
	}

	/**
	 * Create and write a log entry.
	 * @param logLevel Level of the entry.
	 * @param format Format of the entry to create. Additional arguments are permitted for substitution.
	 */
	virtual void log(ILoggerLevel logLevel, const char* format, ...) = 0;

	/**
	 * Set logging level.
	 * @param logLevel Logging level to set.
	 */
	virtual void setLevel(ILoggerLevel logLevel) = 0;

	/**
	 * Get the current logger instance.
	 * @return Logger instance.
	 */
	static ILogger& get() {
		return *_current;
	}

	/**
	 * Sets the current logger instance.
	 * @param log Logger instance.
	 */
	static void set(ILogger* log) {
		_current = log;
	}

	/**
	 * Gets the text associated with the logger level.
	 * @param level Logger level.
	 * @return String representation of the logger level.
	 */
	std::string getLevelText(ILoggerLevel level) {
		return LoggerLevelText[(int) level];
	}
};

} /* namespace biasbase */
#endif /* ILOGGER_H_ */
